#import "Tile.h";
#import "Tileset.h"
#import "State.h"
static TileSet* groundSet;
static TileSet* buildingSet;
static TileSet* itemSet;
static TileSet* unitSet;
static TileSet* roofSet;
static TileSet* skySet;
static TileSet* spaceSet;

@implementation Tile
+(void)initialize{
	groundSet=nil;
	buildingSet	=nil;
	itemSet	=nil;
	unitSet=nil;
	roofSet=nil;
	skySet	=nil;
	spaceSet=nil;

}
@synthesize  ground,item,building,sky,roof,space,unit ;
-(id)initWithDictionary:(NSMutableDictionary*)dic{
 	self.x=[[dic objectForKey:@"x"] intValue];
	self.y=[[dic objectForKey:@"y"] intValue];
	self.ground=[[dic objectForKey:@"ground"] intValue];
	self.building=[[dic objectForKey:@"building"] intValue];
	self.unit=[[dic objectForKey:@"unit"] intValue];
	self.item=[[dic objectForKey:@"item"] intValue];
	self.sky=[[dic objectForKey:@"sky"] intValue];
	self.roof=[[dic objectForKey:@"roof"] intValue];
	self.space=[[dic objectForKey:@"space"] intValue];
	return self;
}
-(NSMutableDictionary*) toDictionary{
	NSMutableDictionary*dic=[super toDictionary];
	[dic setValue:[NSNumber numberWithInt:ground] forKey:@"ground"];
	[dic setValue:[NSNumber numberWithInt:building] forKey:@"building"];
	[dic setValue:[NSNumber numberWithInt:unit] forKey:@"unit"];
	[dic setValue:[NSNumber numberWithInt:item] forKey:@"item"];
	[dic setValue:[NSNumber numberWithInt:sky] forKey:@"sky"];
	[dic setValue:[NSNumber numberWithInt:roof] forKey:@"roof"];
	[dic setValue:[NSNumber numberWithInt:space] forKey:@"space"];
	return dic;
}

+(void)setGroundSet:(TileSet*)set{
	groundSet=set;
}
+(void)setBuildingSet:(TileSet*)set{
	buildingSet=set;
}
+(void)setItemSet:(TileSet*)set{
	itemSet	=set;
}
+(void)setUnitSet:(TileSet*)set{
	unitSet=set;
}
+(void)setRoofSet:(TileSet*)set{
	roofSet=set;
}
+(void)setSkySet:(TileSet*)set{
	skySet=set;
}
+(void)setSpaceSet:(TileSet*)set{
	spaceSet=set;
}
-(void)drawRect:(CGRect)r{
if(groundSet!=nil && ground!=0)		[[groundSet getImage:ground] drawInRect:r ];
if(buildingSet!=nil && building!=0) [[buildingSet getImage:building] drawInRect:r ];
if(itemSet!=nil && item!=0)			[[itemSet getImage:item] drawInRect:r ];
if(unitSet!=nil && unit!=0)			[[unitSet getImage:unit] drawInRect:r ];
if(roofSet!=nil && roof!=0)			[[roofSet getImage:roof] drawInRect:r ];
if(skySet!=nil && sky!=0)			[[skySet getImage:sky] drawInRect:r ];
if(spaceSet!=nil && space!=0)		[[spaceSet getImage:space] drawInRect:r ];

}
@end